﻿using QG.JobBack.BLL.IService;
using QG.JobBack.DAL;
using QH.JobBack.Model;
using System.Linq;

namespace QG.JobBack.BLL.Service
{
    public class UserService : BaseRepository<Admininfo>, IUserServices
    {
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="admininfo"></param>
        /// <returns></returns>
        public ResponseResult<Admininfo> Login(Admininfo admin)
        {
            ResponseResult<Admininfo> response = new ResponseResult<Admininfo>();
            //查询用户信息
            //var password = MD5Encrypt.Encrypt(admin.AdminPwd);
            var modle = Query(a => a.AdminName == admin.AdminName && a.AdminPwd == admin.AdminPwd);
            //如果用户名信息不为空
            if (modle != null)
            {                
                response.code = (int)ResponseEnum.Status;
                response.data = modle;
                response.msg = "登录成功";
                response.success = true;

            }
            else
            {
                response.code = (int)ResponseEnum.Error;
                response.msg = "用户名或密码错误";
                response.success = false;

            }
            return response;
        }

      
    }
}
